<?php

class Emms_Form_Loan_Execute extends HTech_Form
{    
    public function __construct($master) 
    {
        parent::__construct();   
        $this->setName('Execute');
        
        $this->setAttrib('title', $this->translate("Loan application"));
        
        //$loanMasterId = new Zend_Form_Element_Hidden('LoanMasterId');        
        
        $checkNumber = new Zend_Form_Element_Text('CheckNumber');
        $checkNumber->setLabel("Check number")
            ->setRequired(true)
            ->addValidator('NotEmpty', true, array('messages' => $this->translate("Required field, can't be empty")))
            ->addFilter('Alnum', array('allowwhitespace' => true))
            ->addValidator('StringLength',false,
                array(
                    'min'      => 2,
                    'max'      => 128,
                    'messages' => $this->translate("From %min% to %max% characters only")
                ));
        
        $fundId = new Zend_Form_Element_Select('FundId');
        $fundId->setLabel("Fund")  
            ->setRequired(true)               
            ->setAttrib('size','5')
            ->addValidator('GreaterThan', true, array('min' => 0))
            ->addMultiOptions($this->_db->fetchPairs('
                select f.FundId, f.Fund from lnk_programs_funds pf 
                left join funds f on f.FundId = pf.FundId 
                where pf.ProgramId = ?', $master->ProgramId))
            ->addErrorMessage($this->translate("Required field, can't be empty")); 
                   
        $comments = new Zend_Form_Element_Textarea('Comments');
        $comments->setLabel("Comments")
            ->addFilter('Alnum', array('allowwhitespace' => true))
            ->setAttrib('rows', 4); 
        
        $submit = new Zend_Form_Element_Submit('Submit');
        $submit->setLabel("Submit")
            ->addDecorator(new HTech_Form_Decorator_Button(array('type' => 'submit')));
                
        $this->addElements(array($checkNumber, $fundId, $comments, $submit));
    } 
}